import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';

const routes: Array<RouteRecordRaw> = [
  {
    path: '',
    redirect: 'home',
  },
  {
    path: '/front',
    component: () => import('/@/views/front/layout/index.vue'),
    children: [
      {
        path: '/home',
        component: () => import('/@/views/front/home/index.vue'),
      },
      {
        path: '/merge',
        component: () => import('/@/views/front/merge/index.vue'),
        redirect: '/merge/product',
        children: [
          {
            path: '/merge/product',
            component: () => import('/@/views/front/merge/merge-product.vue'),
          },
          {
            path: '/merge/detail',
            component: () => import('/@/views/front/merge/detail/index.vue'),
          },
        ],
      },
      {
        path: '/merge/scgcpg',
        component: () => import('/@/views/front/merge/merge-scgcpg.vue'),
      },
      {
        path: '/sandstorm',
        component: () => import('/@/views/front/sandstorm/index.vue'),
        redirect: '/sandstorm/product',
        children: [
          {
            path: '/sandstorm/product',
            component: () => import('/@/views/front/sandstorm/sandstorm-product.vue'),
          },
          {
            path: '/sandstorm/detail',
            component: () => import('/@/views/front/sandstorm/detail/index.vue'),
          },
        ],
      },
      {
        path: '/forcast',
        component: () => import('/@/views/front/forcast/index.vue'),
        redirect: '/forcast/product',
        children: [
          {
            path: '/forcast/product',
            component: () => import('../views/front/forcast/forcast-product.vue'),
          },
          {
            path: '/forcast/detail',
            component: () => import('/@/views/front/forcast/detail/index.vue'),
          },
        ],
      },
    ],
  },
  // 404页面
  {
    path: '/404',
    name: 'NotFound',
    component: () => import('/@/views/not-found.vue'),
  },
  // 无匹配项重定向至404页面
  {
    path: '/:pathMatch(.*)',
    redirect: '/404',
  },
];

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_PUBLIC_PATH),
  routes,
});

export default router;
